import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBShop035-客户管理管理客户积分调整流程"

str1="cyy"
num1=10000
num2=10000
str4="买手机送积分"
# 1.点击“积分调整”按钮。
firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,"客户管理","管理客户")
str3=firefox.find_element_by_xpath("//td[text()='%s']/following-sibling::td[6]"%str1).text
l="^"
r1=""+""+"/"+""+""
num3=reGetString(str3,l,r1)
r2="$"
num4=reGetString(str3,r1,r2)
firefox.find_element_by_xpath("//td[text()='%s']/following-sibling::td[7]/a[3]"%str1).click()
time.sleep(2)
# 2.被调整人“cyy”,消费积分和等级积分“10000”，备注内容“买手机送积分”。
firefox.find_element_by_id("change_user_integral_num").send_keys(num1)
firefox.find_element_by_id("change_integral_type_2_num").send_keys(num1)
firefox.find_element_by_id("integral_log_info").send_keys(str4)
# 3.点击“提交调整”按钮，显示积分都为10000.
firefox.find_element_by_xpath("//button[text()='提交调整']").click()
time.sleep(2)
# 断言
str9=firefox.find_element_by_xpath("//td[text()='%s']/following-sibling::td[6]"%str1).text
num8=reGetString(str9,l,r1)
num9=reGetString(str9,r1,r2)
if int(num8)==int(num3)+num1 and int(num9)==int(num4)+num2:
    writeLog("%s 测试通过" % testCase)
else:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()